Remove the final (?) vestigest of microseconds as a separate member.
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 22 Jul 2013 04:44:06 +0000 (04:44 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 22 Jul 2013 04:44:06 +0000 (04:44 +0000)
Gopal was a stupid bug within gopal itself.  creation_time was being written
three independent times per line (sigh) and once MS quit being a separate field,
it was no longer retained across writes.

git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4465 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/csv_util.cc
gpsbabel/defs.h
gpsbabel/gopal.cc
gpsbabel/unicsv.cc
gpsbabel/waypt.cc

index 28185d6df878600a5a466360fca13d15d652470a..54f1d20010a0b322ef4fd89aaf2135d910e541cf 100644 (file)
@@ -1222,7 +1222,8 @@ xcsv_parse_val(const char* s, waypoint* wpt, const field_map_t* fmp,
     break;
   case XT_NET_TIME: {
     time_t tt = wpt->GetCreationTime();
-    dotnet_time_to_time_t(atof(s), &tt, &wpt->microseconds);
+fatal("XT_NET_TIME can't have possibly ever worked.");
+//    dotnet_time_to_time_t(atof(s), &tt, &wpt->microseconds);
     }
     break;
   case XT_GEOCACHE_LAST_FOUND:
index d76bc974df4e2a5aa66e5000b9a6862fef16001b..28529ea712cf46acbbc53734782f2839b5cfdb9f 100644 (file)
@@ -447,7 +447,6 @@ public:
   description(NULL), 
   notes(NULL), 
   url_next(NULL), 
-  microseconds(0), 
   route_priority(0), 
   hdop(0), 
   vdop(0), 
@@ -537,7 +536,6 @@ public:
     creation_time = creation_time.addMSecs(ms);
   }
   gpsbabel::DateTime creation_time;
-  int microseconds;    /* Optional millionths of a second. */
 
   /*
    * route priority is for use by the simplify filter.  If we have
index d244341920a57c60b185a676a13760395157a5bd..710b80b8441b7ed43ce5057ff3c38822b4d83d43 100644 (file)
@@ -52,6 +52,7 @@
 #include <ctype.h>
 #include "csv_util.h"
 #include <time.h>
+#include <math.h>
 #include "strptime.h"
 #include "jeeps/gpsmath.h"
 #include "grtcirc.h"
@@ -213,14 +214,13 @@ gopal_read(void)
     //TICK;    TIME;   LONG;     LAT;       HEIGHT; SPEED;  Fix; HDOP;    SAT
     //3801444, 080558, 2.944362, 43.262117, 295.28, 0.12964, 2, 2.900000, 3
     c = csv_lineparse(str, ",", "", column++);
+    double millisecs = 0;
     while (c != NULL) {
       switch (column) {
       case  0: /* "-" */       /* unknown fields for the moment */
         sscanf(c, "%lu", &microsecs);
-        wpt->SetCreationTime(microsecs / 1000000, microsecs % 1000000);
-// FIXME: this is totally papering over a problem where creation time is
-// being overwritten later.
-wpt->microseconds = microsecs % 1000000;
+        // Just save this; we'll use it on the next field.
+        millisecs = /*lround*/(microsecs % 1000000) / 1000.0;
         break;
       case  1:                         /* Time UTC */
         sscanf(c,"%lf",&hmsd);
@@ -233,7 +233,9 @@ wpt->microseconds = microsecs % 1000000;
         tm.tm_year=trackdate.tm_year;
         tm.tm_mon=trackdate.tm_mon;
         tm.tm_mday=trackdate.tm_mday;
+        // This will probably be overwritten by field 9...if we have 9 fields.
         wpt->creation_time = tx+((((time_t)tm.tm_hour * 60) + tm.tm_min) * 60) + tm.tm_sec;
+        wpt->creation_time = wpt->creation_time.addMSecs(millisecs);
         if (global_opts.debug_level > 1) {
           strftime(tbuffer, sizeof(tbuffer), "%c", gmtime(&wpt->creation_time));
           printf("parsed timestamp: %s\n",tbuffer);
@@ -292,6 +294,7 @@ wpt->microseconds = microsecs % 1000000;
           fatal("Bad date '%s'.\n", c);
         }
         wpt->creation_time += mkgmtime(&tm2);
+        wpt->creation_time = wpt->creation_time.addMSecs(millisecs);
         break;
       case 10:  // Unknown.  Ignored.
       case 11:  // Bearing.  Ignored.
index fbc71311f7a7248d2d5b2f094a5081e5a0e94b4f..739aeceaa4d1f328d922e64df30978e24ac582eb 100644 (file)
@@ -1192,7 +1192,7 @@ unicsv_parse_one_line(char *ibuf)
     }
 
     if (msec >= 0) {
-      wpt->creation_time.addMSecs(msec);
+      wpt->creation_time = wpt->creation_time.addMSecs(msec);
     }
 
     if (opt_utc) {
index eb35939c9900eed7ee8101c29f6df92d1dfcfea1..5c641b54cfc18a6788d6d35ac7e0d5dcc4379f24 100644 (file)
@@ -669,9 +669,7 @@ waypoint::CreationTimeXML() const
     return NULL;
   }
 
-  QDateTime dt = GetCreationTime();
-  dt = dt.addMSecs(MICRO_TO_MILLI(microseconds));
-  dt = dt.toUTC();
+  QDateTime dt = GetCreationTime().toUTC();
 // qDebug() << dt.toString("dd.MM.yyyy hh:mm:ss.zzz")  << " CML " << microseconds;
 
   const char* format = "yyyy-MM-ddTHH:mm:ssZ";